package com.stormrage.edu.dao.edu.impl;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.stormrage.edu.dao.edu.EduModuleDao;
import com.stormrage.entity.edu.EduModule;
import com.stormrage.entity.edu.rep.EduModuleRep;
import com.stormragetech.core.dao.MysBaseDao;
import com.stormragetech.core.exception.StormrageTechException;

/**
 * @author www.stormragetech.com
 * @date 2016年1月19日
 * @version 1.0.0
 */
@Repository
public class EduModuleDaoImpl extends MysBaseDao implements EduModuleDao {

	private static final Logger logger = LoggerFactory.getLogger(EduModuleDaoImpl.class);

	@Override
	public List<EduModuleRep> queryRepListByMajorId(final Map<String, Object> map) throws StormrageTechException {

		logger.debug(" 【 Dao 】- 【 EduModuleDao 】- 【 queryRepListByMajorId 】- 开始运行 ");

		final String query = "SELECT a.id, a.module, a.ness FROM edu_module AS a, edu_major_module AS b"
				+ " WHERE a.id = b.module_id AND b.major_id = :id ORDER BY a.id";
		logger.debug(" 数据库执行语句为 " + query);

		List<EduModuleRep> array = queryList(query, EduModuleRep.class, map);

		logger.debug(" 【 Dao 】- 【 EduModuleDao 】- 【 queryRepListByMajorId 】- 完成运行 ");
		return array;
	}

	@Override
	public List<EduModule> queryListByMajorNess(final Map<String, Object> map) throws StormrageTechException {

		logger.debug(" 【 Dao 】- 【 EduModuleDao 】- 【 queryRepListByMajorNess 】- 开始运行 ");

		final String query = "SELECT a.* FROM edu_module AS a, edu_major_module AS b"
				+ " WHERE a.id = b.module_id AND b.major_id = :id AND a.ness = :ness ORDER BY a.id";
		logger.debug(" 数据库执行语句为 " + query);

		List<EduModule> array = queryList(query, EduModule.class, map);

		logger.debug(" 【 Dao 】- 【 EduModuleDao 】- 【 queryRepListByMajorNess 】- 完成运行 ");
		return array;
	}

}
